package com.cjxt.ams.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author XueYunFei
 * @version V1.0
 * @Description: Kaptcha的配置
 * @className: KaptchaConfig
 * @date 2021/11/22 15:04
 * @company:华勤技术股份有限公司
 * @copyright: Copyright (c) 2021
 */

@Configuration
public class KaptchaConfig {
    @Bean
    public DefaultKaptcha producer() {
        Properties properties = new Properties();
        properties.put("kaptcha.border", "yes");//图片边框,默认黑色
//        properties.put("kaptch.broder.color","blue");//图片边框颜色
        properties.put("kaptcha.textproducer.char.length","4");//验证码长度
        properties.put("kaptcha.textproducer.font.color", "blue");//字体颜色
        properties.put("kaptcha.textproducer.char.space", "3");//验证码文本字符间距
        properties.put("kaptcha.textproducer.font.names", "Arial,Courier,cmr10,宋体,楷体,微软雅黑");
        Config config=new Config(properties);
        DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;

    }
}
